const {
  OPENID_ISSUER,
  OPENID_SCOPE,
  OPENID_CLIENT_ID,
  OPENID_CLIENT_SECRET,
  OPENID_SUCCESS_REDIRECT,
  OPENID_CALLBACK,
  OPENID_NONCE,
  OPENID_NONCE_SECRET,
} = process.env;


const dev = {
  provider: 'lilly',
  authScheme: 'openid connect',
  module: 'passport-cirrus-ping',
  // server-side params
  clientID: OPENID_CLIENT_ID,
  clientSecret: OPENID_CLIENT_SECRET,
  issuer: OPENID_ISSUER,
  nonce: OPENID_NONCE_SECRET,
  scope: OPENID_SCOPE,
  // client-side params
  authPath: '/auth/ping',
  callbackPath: '/auth/token',
  callbackHTTPMethod: 'post',
  successRedirect: OPENID_SUCCESS_REDIRECT,
  failureRedirect: '/auth/ping',
  authOptions: {
    successRedirect: OPENID_SUCCESS_REDIRECT,
    failureRedirect: '/auth/ping',
  },
};

const stg = {
  provider: 'lilly',
  authScheme: 'openid connect',
  module: 'passport-cirrus-openid',
  // server-side params
  clientID: OPENID_CLIENT_ID,
  clientSecret: OPENID_CLIENT_SECRET,
  issuer: OPENID_ISSUER,
  nonce: OPENID_NONCE,
  scope: OPENID_SCOPE,
  // client-side params
  authPath: '/auth/ping',
  callbackPath: OPENID_CALLBACK,
  successRedirect: OPENID_SUCCESS_REDIRECT,
  failureRedirect: '/auth/ping',
  authOptions: {
    successRedirect: OPENID_SUCCESS_REDIRECT,
    failureRedirect: '/auth/ping',
  },
};

module.exports = {
  ping: process.env.NODE_ENV === 'development' ? dev : stg,
};
